package com.lzh.consumer;


import com.lzh.constant.MQConstant;
import com.lzh.domain.dto.LoginMessageDTO;
import com.lzh.service.WebSocketService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: lizhenhua
 *
 */
@RocketMQMessageListener(consumerGroup = MQConstant.LOGIN_MSG_GROUP,
        topic = MQConstant.LOGIN_MSG_TOPIC, messageModel = MessageModel.BROADCASTING)
@Component
public class MsgLoginConsumer implements RocketMQListener<LoginMessageDTO> {
    @Autowired
    private WebSocketService webSocketService;

    @Override
    public void onMessage(LoginMessageDTO loginMessageDTO) {
        System.out.println("消費 ====>" + loginMessageDTO);
        System.out.println("使用快速开发");
        //尝试登录登录
        webSocketService.loginSuccess(loginMessageDTO.getCode(), loginMessageDTO.getUid());
    }

}
